Methods
(static) reduceTo(constructor) → {function}
- Source:
- Since:
- 0.3.0
Return a function expecting a reducer function and returning a reduce function with an instance of the provided constructor as the initial value and expecting the array to reduce.
Example
> reduceFromEmptyObject = reduceTo(Object)
> foo = reduceFromEmptyObject((acc, x) => {
acc[x.id] = x.name;
return acc;
})
> foo([{id: '00', name: 'a'}, {id: '11', name: 'b'}])
Object {11: 'b', 00: 'a'}
Parameters:
Name | Type | Description |
---|---|---|
constructor |
object |
Returns:
- (Any -> Any):reduceCb -> (Array -> Any)
- Type
- function